#define _CRT_SECURE_NO_WARNINGS 1
struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2)
{
    if (list1 == NULL)
        return list2;
    if (list2 == NULL)
        return list1;
    struct ListNode* NewHead = NULL, * Ptail = NULL;
    while (list1 != NULL && list2 != NULL)
    {
        if (list1->val > list2->val)
        {
            if (Ptail == NULL)
            {
                NewHead = Ptail = list2;
            }
            else
            {
                Ptail->next = list2;
                Ptail = Ptail->next;
            }
            list2 = list2->next;
        }
        else
        {
            if (Ptail == NULL)
            {
                NewHead = Ptail = list1;
            }
            else
            {
                Ptail->next = list1;
                Ptail = Ptail->next;
            }
            list1 = list1->next;
        }
    }
    if (list1 != NULL)
        Ptail->next = list1;
    if (list2 != NULL)
        Ptail->next = list2;
    return NewHead;
}
